package com.dongjia168.eurekaServer.application.configer;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @Auther: yaodx
 * @Date: 2018/7/9 13:25
 * @Description: SpringSecurity配置类
 */
@Configuration
@EnableWebSecurity
public class SpringSecurityConfiger extends WebSecurityConfigurerAdapter {
    @Override protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/login").permitAll()                              //访问：/logoin 无需登录认证权限,其他均需要认证
                .anyRequest().authenticated().and().csrf().disable().httpBasic();           //引掉csrf,不引的话启动时会报主机找不到。
    }
}
